package animal;

class Animal{
    String name;
    private int leg;

    public void setLeg(int n) {
        if(n>0){
            leg = n;
        }
        else{
            System.out.println("输入腿数不正确");
        }
    }

    public int getLeg(){
        return leg;
    }

    public void eat(){
        System.out.println(name + "吃");
    }
}

public class AnimalTest {
    public static void main(String[] args) {
        Animal animal1=new Animal();
        animal1.name="兔子";
        animal1.eat();
        animal1.setLeg(4);
        System.out.println(animal1.name+"有"+animal1.getLeg()+"条腿");


    }
}
